else
this._network = null;
- if (Config.HAVE_BLUETOOTH)
- this._bluetooth = new imports.ui.status.bluetooth.Indicator();
- else
- this._bluetooth = null;
-
this._power = new imports.ui.status.power.Indicator();
this._powerProfiles = new imports.ui.status.powerProfiles.Indicator();
this._volume = new imports.ui.status.volume.Indicator();
if (this._network)
this._indicators.add_child(this._network);
- if (this._bluetooth)
- this._indicators.add_child(this._bluetooth);
this._indicators.add_child(this._volume);
this._indicators.add_child(this._power);
this._indicators.add_child(this._powerProfiles);
if (this._network)
this.menu.addMenuItem(this._network.menu);
- if (this._bluetooth)
- this.menu.addMenuItem(this._bluetooth.menu);
-
this.menu.addMenuItem(this._power.menu);
this.menu.addMenuItem(this._powerProfiles.menu);
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.setMenu(new QuickSettingsMenu(this, N_QUICK_SETTINGS_COLUMNS));
+ if (Config.HAVE_BLUETOOTH)
+ this._bluetooth = new imports.ui.status.bluetooth.Indicator();
+ else
+ this._bluetooth = null;
+
this._remoteAccess = new imports.ui.status.remoteAccess.RemoteAccessApplet();
this._location = new imports.ui.status.location.Indicator();
this._thunderbolt = new imports.ui.status.thunderbolt.Indicator();
this._indicators.add_child(this._thunderbolt);
this._indicators.add_child(this._location);
this._indicators.add_child(this._nightLight);
+ if (this._bluetooth)
+ this._indicators.add_child(this._bluetooth);
this._indicators.add_child(this._rfkill);
this._indicators.add_child(this._unsafeMode);
this._addItems(this._remoteAccess.quickSettingsItems);
this._addItems(this._thunderbolt.quickSettingsItems);
this._addItems(this._location.quickSettingsItems);
+ if (this._bluetooth)
+ this._addItems(this._bluetooth.quickSettingsItems);
this._addItems(this._nightLight.quickSettingsItems);
this._addItems(this._rfkill.quickSettingsItems);
this._addItems(this._unsafeMode.quickSettingsItems);
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported Indicator */
-const { Gio, GLib, GnomeBluetooth, GObject } = imports.gi;
+const {Gio, GLib, GnomeBluetooth, GObject} = imports.gi;
-const Main = imports.ui.main;
-const PanelMenu = imports.ui.panelMenu;
-const PopupMenu = imports.ui.popupMenu;
+const {QuickToggle, SystemIndicator} = imports.ui.quickSettings;
-const { loadInterfaceXML } = imports.misc.fileUtils;
+const {loadInterfaceXML} = imports.misc.fileUtils;
const BUS_NAME = 'org.gnome.SettingsDaemon.Rfkill';
const OBJECT_PATH = '/org/gnome/SettingsDaemon/Rfkill';
}
});
+const BluetoothToggle = GObject.registerClass(
+class BluetoothToggle extends QuickToggle {
+ _init(client) {
+ super._init({label: _('Bluetooth')});
+
+ this._client = client;
+
+ this._client.bind_property('available',
+ this, 'visible',
+ GObject.BindingFlags.SYNC_CREATE);
+ this._client.bind_property('active',
+ this, 'checked',
+ GObject.BindingFlags.SYNC_CREATE);
+ this._client.bind_property_full('active',
+ this, 'icon-name',
+ GObject.BindingFlags.SYNC_CREATE,
+ (bind, source) => [true, source ? 'bluetooth-active-symbolic' : 'bluetooth-disabled-symbolic'],
+ null);
+
+ this.connect('clicked', () => this._client.toggleActive());
+ }
+});
+
var Indicator = GObject.registerClass(
-class Indicator extends PanelMenu.SystemIndicator {
+class Indicator extends SystemIndicator {
_init() {
super._init();
- this._indicator = this._addIndicator();
- this._indicator.icon_name = 'bluetooth-active-symbolic';
-
this._client = new BtClient();
- this._client.connectObject(
- 'notify::active', () => this._sync(),
- 'devices-changed', () => this._sync(), this);
+ this._client.connect('devices-changed', () => this._sync());
- this._item = new PopupMenu.PopupSubMenuMenuItem(_('Bluetooth'), true);
- this._client.bind_property('available',
- this._item, 'visible',
- GObject.BindingFlags.SYNC_CREATE);
-
- this._toggleItem = new PopupMenu.PopupMenuItem('');
- this._toggleItem.connect('activate', () => this._client.toggleActive());
- this._item.menu.addMenuItem(this._toggleItem);
+ this._indicator = this._addIndicator();
+ this._indicator.icon_name = 'bluetooth-active-symbolic';
- this._item.menu.addSettingsAction(_('Bluetooth Settings'), 'gnome-bluetooth-panel.desktop');
- this.menu.addMenuItem(this._item);
+ this.quickSettingsItems.push(new BluetoothToggle(this._client));
- Main.sessionMode.connect('updated', this._sync.bind(this));
this._sync();
}
const connectedDevices = devices.filter(dev => dev.connected);
const nConnectedDevices = connectedDevices.length;
- let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
-
- this.menu.setSensitive(sensitive);
this._indicator.visible = nConnectedDevices > 0;
-
- this._item.icon.icon_name = this._client.active
- ? 'bluetooth-active-symbolic' : 'bluetooth-disabled-symbolic';
-
- if (nConnectedDevices > 1)
- /* Translators: this is the number of connected bluetooth devices */
- this._item.label.text = ngettext('%d Connected', '%d Connected', nConnectedDevices).format(nConnectedDevices);
- else if (nConnectedDevices === 1)
- this._item.label.text = connectedDevices[0].alias;
- else if (this._client.active)
- this._item.label.text = _('Bluetooth On');
- else
- this._item.label.text = _('Bluetooth Off');
-
- this._toggleItem.label.text = this._client.active ? _('Turn Off') : _('Turn On');
}
});